import { Component } from 'react';
import './index.scss';
import { http } from '../../utils/http';
import { getCurrentCity } from '../../utils';

export default class Search extends Component {
  state = {
    curCity: null,
  };
  async componentDidMount() {
    const curCity = await getCurrentCity();
    this.setState({ curCity: curCity.label });
  }
  render() {
    const { push } = this.props.history;
    const { curCity } = this.state;
    return (
      <div className='search'>
        <div className='left'>
          <div className='location' onClick={() => push('/citylist')}>
            <span>
              {curCity}
              <i className='iconfont icon-arrow'></i>
            </span>
          </div>
          <div className='input-box' onClick={() => push('/search')}>
            <i className='iconfont icon-seach'></i>
            <span>请输入小区或地址</span>
          </div>
        </div>
        <div className='right' onClick={() => push('/map')}>
          <i className='iconfont icon-map'></i>
        </div>
      </div>
    );
  }
}
